package com.example.fuluchou.common.exception;

import com.example.fuluchou.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

//@Data 会生成自己的 equals hashcode，想要使用父类的，需要添加注解 @EqualsAndHashCode(callSuper = true)
@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {

    private Integer code;

    private String message;

    public ServiceException() {
    }

    public ServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }

}
